{% import "form_helpers.html" as form_helpers %}
<article itemscope itemtype="http://schema.org/Product">
    <heading>
        <h1>{% if not item.active %}<i class="icon-info-sign" title="{{ _('This item is inactive, so only you can see it.') }}"></i>{% endif %}
            <a href="{{ item.url() }}" itemprop="name">{{ item.title }}</a>
        </h1>
    </heading>
    {% if item.youtube %}
        <div>
        {{ item.youtube_rendered|safe }}
        </div>
    {% endif %}
    {% if item.image %}
        <div>
        <img src="{{ url_for('blob', key=item.image) }}" width="400em" height="400em">
        </div>
    {% endif %}
    <span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <span class="badge badge-inverse" itemprop="price">{{ item.price }}</span>
    </span>
    {{ form_helpers.render_stars(item.average_rating|default(-1)|int, 5) }}
    <p>
        {{ _('Created') }}: <time class="timeago" datetime="{{ item.created.isoformat() }}Z">{{ item.created.ctime() }}</time>
    </p>
    <p itemprop="description">{{ item.description_rendered|safe }}</p>
    <div class="form-actions">
        <a href="{{ item.url() }}" class="btn">{{ _('Details') }}</a>
        {% if item.editable_by(current_user) %}
            <a class="btn btn-primary" href="{{ url_for('item_update', id=item.key.id(), slug=item.slug) }}">{{ _('Update') }}</a>
            <form method="post" action="{{ url_for('item_delete', id=item.key.id(), slug=item.slug) }}" style="display: inline">
                {{ item_delete_form.csrf_token }}
                <input type="submit" class="btn btn-danger" value="{{ _('Delete') }}">
            </form>
        {% endif %}
        {% if current_user.get_id() != item.seller_id and current_user.is_authenticated() %}
            <a href="{{ url_for('message_send', to=item.seller.email, subject=item.key.id()) }}" class="btn btn-inverse">{{ _('Contact Seller') }}</a>
        {% endif %}
        <div class="pull-right">
            <div class="g-plus" data-action="share" data-annotation="none" data-height="28" data-href="{{ item.url() }}"></div>
        </div>
    </div>
</article>
